﻿function convert() {
    //Get all the values
    var amount = $('#amount').val();
    var from = $('#fromCurrency').val();
    var to = $('#toCurrency').val();
    //Make data string
    var dataString = "q=" + amount + from + "=?" + to;
    $.ajax({
        type: "GET",
        datatype: "json",
        url: "http://www.google.com/ig/calculator?hl=en&" + dataString,
        headers: {
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        },
        success: function (data) {
            var objj = JSON.stringify(eval("(" + data + ")"));
            var jj = JSON.parse(objj);
            $('#resultsTest').html(jj.rhs);
        },
        error: function (data) {
            alert('error');
        }
    });

    var divtest = $("#colorSubSelector").attr("style");
    var parts = divtest.split(':');
    var output = '<span>' + parts[1] + '</span>';
    $("#divClassTile").attr("style", "background-color:" + parts[1]);
}